package com.ruoyi.project.jiaqin.thrclasstrend.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.thrclasstrend.domain.ThrClassTrend;
import com.ruoyi.project.jiaqin.thrclasstrend.service.IThrClassTrendService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 三级分类价格走势Controller
 * 
 * @author admin
 * @date 2021-01-09
 */
@Controller
@RequestMapping("/jiaqin/thrclasstrend")
public class ThrClassTrendController extends BaseController
{
    private String prefix = "jiaqin/thrclasstrend";

    @Autowired
    private IThrClassTrendService thrClassTrendService;

    @RequiresPermissions("jiaqin:thrclasstrend:view")
    @GetMapping()
    public String thrclasstrend()
    {
        return prefix + "/thrclasstrend";
    }

    /**
     * 查询三级分类价格走势列表
     */
    @RequiresPermissions("jiaqin:thrclasstrend:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ThrClassTrend thrClassTrend)
    {
        startPage();
        List<ThrClassTrend> list = thrClassTrendService.selectThrClassTrendList(thrClassTrend);
        return getDataTable(list);
    }

    /**
     * 导出三级分类价格走势列表
     */
    @RequiresPermissions("jiaqin:thrclasstrend:export")
    @Log(title = "三级分类价格走势", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ThrClassTrend thrClassTrend)
    {
        List<ThrClassTrend> list = thrClassTrendService.selectThrClassTrendList(thrClassTrend);
        ExcelUtil<ThrClassTrend> util = new ExcelUtil<ThrClassTrend>(ThrClassTrend.class);
        return util.exportExcel(list, "thrclasstrend");
    }

    /**
     * 新增三级分类价格走势
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存三级分类价格走势
     */
    @RequiresPermissions("jiaqin:thrclasstrend:add")
    @Log(title = "三级分类价格走势", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ThrClassTrend thrClassTrend)
    {
        return toAjax(thrClassTrendService.insertThrClassTrend(thrClassTrend));
    }

    /**
     * 修改三级分类价格走势
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ThrClassTrend thrClassTrend = thrClassTrendService.selectThrClassTrendById(id);
        mmap.put("thrClassTrend", thrClassTrend);
        return prefix + "/edit";
    }

    /**
     * 修改保存三级分类价格走势
     */
    @RequiresPermissions("jiaqin:thrclasstrend:edit")
    @Log(title = "三级分类价格走势", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ThrClassTrend thrClassTrend)
    {
        return toAjax(thrClassTrendService.updateThrClassTrend(thrClassTrend));
    }

    /**
     * 删除三级分类价格走势
     */
    @RequiresPermissions("jiaqin:thrclasstrend:remove")
    @Log(title = "三级分类价格走势", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(thrClassTrendService.deleteThrClassTrendByIds(ids));
    }
}
